using SheLife.Domain.Common;

namespace SheLife.Domain.Interfaces;

/// <summary>
/// 通用仓储接口
/// </summary>
/// <typeparam name="T">实体类型</typeparam>
public interface IRepository<T> where T : BaseEntity
{
    // 基本CRUD操作
    Task<T?> GetByIdAsync(Guid id);
    Task<IEnumerable<T>> GetAllAsync();
    Task<IEnumerable<T>> FindAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate);
    Task<T> AddAsync(T entity);
    Task UpdateAsync(T entity);
    Task DeleteAsync(T entity);
    
    // 分页查询
    Task<(IEnumerable<T> Items, int TotalCount)> GetPagedAsync(int pageIndex, int pageSize);
    Task<(IEnumerable<T> Items, int TotalCount)> GetPagedAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate, int pageIndex, int pageSize);
    
    // 批量操作
    Task AddRangeAsync(IEnumerable<T> entities);
    Task UpdateRangeAsync(IEnumerable<T> entities);
    Task DeleteRangeAsync(IEnumerable<T> entities);
    
    // 统计查询
    Task<int> CountAsync(System.Linq.Expressions.Expression<Func<T, bool>>? predicate = null);
    Task<bool> ExistsAsync(System.Linq.Expressions.Expression<Func<T, bool>> predicate);
}